package com.istock.state.demo.service;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.istock.base.common.api.model.ApiBaseResponse;
import com.istock.state.demo.api.NewMockService;
import com.istock.state.demo.model.OrderInfo;
import com.istock.state.demo.model.OrderPay;

/** 错误场景的编码
 * @author Administrator
 *
 */
@Repository("badService")
public class BadService {

	@Autowired
	private OrderPayService orderPayService;
	@Autowired
	private NewMockService mockService;
	
	
	
	@Transactional
	public Map<String , Object> handlerOrder(OrderInfo orderInfo){
		OrderPay payOrder = orderPayService.createPay(orderInfo.getId(), orderInfo.getAmount());
		Map<String , Object> paramMap = new HashMap<String , Object>();
		paramMap.put("payId", payOrder.getId());
		paramMap.put("amount", payOrder.getAmount());
		ApiBaseResponse<Map<String , Object>> payResponse = mockService.badPay(paramMap);
		return payResponse.getResult();
	}
}
